TASK_DIR:=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))

include ../../../config.mk

# Inputs
SRC := $(TASK_DIR)/src/gen_shoot_hom_plot.R
SHOOT_AND_HOM_VICS_BY_MONTH_AND_CA := $(TASK_DIR)/../prepare_data_for_plot/output/shooting_and_homicide_vics_by_month_and_ca.csv
CA_POPULATION := /projects/2016-027-readi/quant/spaghetti/temporary/ca_population_2016.csv
CONFIG_FILE := $(TASK_DIR)/../hand/config.yaml

# Outputs
OUT_FILE := $(OUT_DIR)/top_shooting_neighborhood_plot_up_to_date.png

# Recipes

$(OUT_FILE): $(SRC) $(CONFIG_FILE) $(SHOOT_AND_HOM_VICS_BY_MONTH_AND_CA) $(CA_POPULATION)
	@mkdir -p $(OUT_DIR)
	@mkdir -p $(PAPER_OUT_DIR)
	@$(R_script) $< \
		--CONFIG_FILE=$(CONFIG_FILE) \
		--SHOOT_AND_HOM_VICS_BY_MONTH_AND_CA=$(SHOOT_AND_HOM_VICS_BY_MONTH_AND_CA) \
		--CA_POPULATION=$(CA_POPULATION) \
		--OUT_FILE=$(OUT_FILE)
	@cp $(OUT_DIR)/*up_to_date* $(PAPER_OUT_DIR)

.PHONY: all clean
.DEFAULT_GOAL=all

all: $(OUT_FILE)

clean:
	rm -rf $(OUT_DIR)
